#include "stdafx.h" 
#include <boost/test/auto_unit_test.hpp>
#include "detail/bmock_result.hpp"

namespace bmock {
	struct test_exception {};
	BOOST_AUTO_TEST_CASE(test_exception_result_get_value) {
		const result_ptr pResult(create_exception(new test_exception()));

		BOOST_CHECK_THROW(pResult->get_value(),const exception_result *);
	}

	BOOST_AUTO_TEST_CASE(test_exception_result_throw_exception) {
		const result_ptr pResult(create_exception(new test_exception()));

		try {
			pResult->get_value();
		} catch (const exception_result *pE) {
			BOOST_CHECK_THROW(pE->throw_exception(),test_exception);
		}
	}

	BOOST_AUTO_TEST_CASE(test_value_result) {
		const int        expected = 129;
		const result_ptr pResult(new value_result(bmock_any(&expected))); 
		bmock_any              result;
		int              i_result;

		BOOST_CHECK_NO_THROW(result = pResult->get_value());
		BOOST_CHECK_NO_THROW(i_result = (int)result);
		BOOST_CHECK_EQUAL(expected,i_result);
	}

	BOOST_AUTO_TEST_CASE(test_void_result) {
		const result_ptr pResult(new void_result());

		BOOST_CHECK_THROW(pResult->get_value(),const void_result *);
	}
}
